var express = require('express')
var fs = require('fs')
var path = require('path')

var router = express.Router()

var datafile = path.join(__dirname, '../api/prodlist.json')
var website = 'http://localhost:8888/'


router.get('/api/getlunbo', function (req, res) {
    // fs.readFile(datafile, 'utf8', function (err, data) {
    //     if (err) {
    //         return res.send('readFile error')
    //     }
    //     var status = 0
    //     var message = JSON.parse(data).message
    //     var content = JSON.stringify({
    //             status: status,
    //             message: message
    //         })
    //         // console.log(JSON.parse(content))
    //     res.send(content)
    // })

    var status = 0
    var message = [
        {url: "www.baidu.com", img: website + "public/img/mt-express.jpg"},
        {url: "www.baidu.com", img: website + "public/img/mt-food.jpg"},
        {url: "www.baidu.com", img: website + "public/img/mt-hotel.jpg"},
        {url: "www.baidu.com", img: website + "public/img/mt-movie.jpg"},
    ]
    var content = JSON.stringify({
        status,
        message
    })
    res.send(content)
})


module.exports = router